package com.hyy.asm.server.handler;

import com.hyy.asm.message.GroupQuitRequestMessage;
import com.hyy.asm.message.GroupQuitResponseMessage;
import com.hyy.asm.server.session.GroupSessionFactory;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

@ChannelHandler.Sharable
public class GroupQuitRequestMessageHandler extends SimpleChannelInboundHandler<GroupQuitRequestMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, GroupQuitRequestMessage msg) throws Exception {
        String groupName = msg.getGroupName();
        GroupSessionFactory.getGroupSession().removeGroup(groupName);
        GroupQuitResponseMessage groupQuitResponseMessage = new GroupQuitResponseMessage(true,"删除"+groupName+"成功");
        ctx.writeAndFlush(groupQuitResponseMessage);
    }
}
